using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
public class Member_Shop_AdsClickRecorde : Member, IRequiresSessionState
{
	protected Literal allAdsEP;
	protected Button Button1;
	protected GridView GridView1;
	protected Label AllRecorde;
	protected TextBox txtEmail;
	protected RegularExpressionValidator RegularExpressionValidator1;
	protected RequiredFieldValidator RequiredFieldValidator1;
	protected TextBox txtPerson;
	protected TextBox txtSubject;
	protected RequiredFieldValidator RequiredFieldValidator2;
	protected TextBox txtFromName;
	protected TextBox txtContent;
	protected RequiredFieldValidator RequiredFieldValidator3;
	protected ImageButton ImageButton1;
	private Pagination _pagehander;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Pagination m_pagehander
	{
		get
		{
			Pagination pagehander;
			if (this._pagehander == null)
			{
				this._pagehander = new Pagination();
				this._pagehander.P_Object = "记录";
				pagehander = this._pagehander;
			}
			else
			{
				pagehander = this._pagehander;
			}
			return pagehander;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.BindList();
		}
	}
	protected void BindList()
	{
		int iD = Fetch.GetID("page");
		if (iD == 0)
		{
		}
		int pageSize = this.GridView1.PageSize;
		this.GridView1.DataSource = this.m_pagehander.GetDataTable("HL_AdsClickRecorde", 1, pageSize, "ID", "Where UserID=" + base.user.UserID, "", this.conn, null);
		this.AllRecorde.Text = this.m_pagehander.P_allNum.ToString();
		this.GridView1.DataBind();
		this.allAdsEP.Text = base.user.UserRes["AdsEP"].ToString();
	}
	protected void CountAds(object sender, EventArgs e)
	{
		long num = 0L;
		this.conn.BeginTransaction();
		try
		{
			if (base.user.UserRes["AdsEP"] != DBNull.Value)
			{
				num = Convert.ToInt64(base.user.UserRes["AdsEP"]);
			}
			if (num > 0L)
			{
				UserExpAction userExpAction = new UserExpAction(this.conn);
				if (!userExpAction.AddUserExpTransaction(base.user.UserID, num, 1, "广告推广获得", "+"))
				{
					this.conn.Rollback();
					this.WriteErrMsg("", Language.Get("Common/Fail", ""), "");
				}
				this.conn.ExecuteTransaction("Update [HL_User] Set AdsEP=0 Where UserID=" + base.user.UserID);
			}
			else
			{
				this.WriteSuccessMsg("系统提示！", "没有要结算的数据。", "");
			}
		}
		catch (Exception ex)
		{
			this.conn.Rollback();
			this.WriteErrMsg("", Language.Get("Common/Fail", ex.Message.ToString()), "");
		}
		this.conn.Commit();
		this.WriteSuccessMsg("", Language.Get("Common/Success"), "Shop_AdsClickRecorde.aspx");
	}
	protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
	{
		Email email = new Email();
		string smtpserver = this.config["MailSmtpServer"].ToString();
		string mailuser = this.config["MailServerUserName"].ToString();
		string mailpassword = this.config["MailServerPassWord"].ToString();
		string mailFrom = this.config["MailServerFrom"].ToString();
		if (email.SendEmail(smtpserver, mailuser, mailpassword, mailFrom, this.txtContent.Text, this.txtEmail.Text, this.txtSubject.Text))
		{
			this.WriteSuccessMsg("", "服务器已经发送出去", "");
		}
		else
		{
			this.WriteErrMsg("", "服务器出现异常", "");
		}
	}
}
